
#此脚本目标：主要是发送数据保证读写一致性的问题 把临时目录的文件 移动到 正式目录

#!/bin/bash

inDir=/home/hmt/data/

intpathFile=`find ${inDir}*`; #注意 这里需要写/xxx/xxx/* , 不然写“*“ 的话就成了目录了

outPath_dataCheck=/home/hmt/dataCheck/
outPath_dataDisk=/home/hmt/dataDisk/
outPath_data4aAuth=/home/hmt/data4aAuth/

for file in $intpathFile;
 do
    byteResOld=`du -b $file | awk {' print $1 '}`;
    sleep 1;  # xxxx
    byteResCurrent=`du -b $file | awk {' print $1 '}`;

    if [[ ${byteResOld} == ${byteResCurrent} ]];then #文件大小相等就可以移动了

        if [[ ${file##*/} == "check"* ]];then  # xxxx
            echo "file相等: "  ${file},${byteResOld},${byteResCurrent}
            mv $file ${outPath_dataCheck}

        elif [[ ${file##*/} == "disk"* ]];then  # xxxx
            echo "file相等: "  ${file},${byteResOld},${byteResCurrent}
            mv $file ${outPath_dataDisk}

        elif [[ ${file##*/} == "4aAuth"* ]];then  # xxxx
            echo "file相等: "  ${file},${byteResOld},${byteResCurrent}
            mv $file ${outPath_data4aAuth}

        else
           echo $file "不是规范文件名 不进行移动" ;

        fi
    else
        echo "file不相等: " ${file},${byteResOld},${byteResCurrent}
    fi
 done
